const Koa = require("koa");
const fire = require("./schedule");

// 创建 Koa 应用实例
const app = new Koa();

// 中间件，返回 IP 地址
app.use(async (ctx) => {
  ctx.type = "application/json";
  ctx.body = {
    error: 0,
    data: new Date(),
    msg: "[任意门]服务运行正常",
  };
});

// 启动服务
const port = 3355;
app.listen(port, () => {
  console.log(`Server is running at http://localhost:${port}`);

  // 加载自动化任务
  fire();
});
